package cn.itcast.nems.studentrecord.dto.change;

import cn.itcast.nems.common.util.LocalDateTimeUtils;
import cn.itcast.nems.studentrecord.service.settlement.SettlementResult;
import lombok.Data;

import java.time.LocalDate;

/**
 * 结课
 *
 * @author liyong
 * create: 2024-01-04 16:02:06
 **/
@Data
public class StudentRecordJournalFinalDTO {
    /**
     * 凭单头ID
     */
    private String journalId;

    /**
     * 凭单行ID
     */
    private String journalLineId;

    /**
     * 需要退学的学籍ID
     */
    private String studentRecordId;

    /**
     * 需要结课的班级ID
     */
    private Integer clazzId;

    /**
     * 需要结课的班级名称
     */
    private String clazzName;

    /**
     * 学籍进班日期;来自于办理结课凭单时候学籍上的对应字段
     */
    private LocalDate inDate;

    /**
     * 学籍出班日期;同本结课凭单“实际结课日期”
     */
    private LocalDate settlementDate;

    /**
     * 实际服务天数;公式：实际结课日期 - 学籍进班日期 + 1
     */
    private Integer actualServiceDays;

    /**
     * 学籍实际应交金额;来自于办理结课凭单时候学籍上的对应字段
     */
    private Integer actualAmountDue;

    public SettlementResult createSettlementResult() {
        SettlementResult result = new SettlementResult();
        result.setServiceDays(this.getActualServiceDays());
        int days = LocalDateTimeUtils.calServiceDays(this.inDate, this.settlementDate);
        result.setSettlementDays(days);
        result.setSettlementAmount(this.getActualAmountDue());
        return result;
    }
}
